<?php
if ( !defined('IN_SCRIPT') || !CAN_EDIT) { header("Location: $current_location"); exit; }

$page_title = $lang['iwish_title_all'] ;
$smarty->assign('content', 'presents');


$page_option = $mode;
$sel_option = ' ORDER BY `user`, `proposal_date` DESC'; 
switch ($mode) {
    case 'waiting':     $sel_option = " AND `approved` = 'N' ORDER BY `user`, `proposal_date` DESC"; 
                        $page_title = $lang['iwish_title_waiting'];
                        break; 
    case 'approved':    $sel_option = " AND `approved` = 'A' ORDER BY `user`, `approval_date` DESC"; 
                        $page_title = $lang['iwish_title_approved'];
                        break;
    case 'presented':   $sel_option = " AND `approved` = 'P' ORDER BY `user`, `presented_date` DESC"; 
                        $page_title = $lang['iwish_title_presented'];
                        break; 

    default: $page_option = ''; break;
}


$presents_list = get_iwish($sel_option);
$p_count = ceil($presents_list['total_rows']/$per_page); // количество страниц
unset($presents_list['total_rows']);

$smarty->assign('page', $page);
$smarty->assign('presents_list', $presents_list);         
$smarty->assign('page_count', $p_count);         
$smarty->assign('page_option', $page_option);         
$smarty->assign('nav_url', $current_location.'/iwish'.($page_option ? '/'.$page_option : '').($p_count > 0 ? '/page': ''));         
if(!empty($page_option)) $smarty->assign('mode', $page_option);
$smarty->assign('is_iwish', true);
?>
